package main

import "fmt"

type Human interface {
	SayHello()
}

type Student struct {
	name  string
	age   int
	sex   string
	score int
}

type Teacher struct {
	name    string
	age     int
	sex     string
	subject string
}

func (s *Student) SayHello() {
	fmt.Printf("大家好，我是%s，我今年%d岁，我是%s生，我的成绩是%d分\n", s.name, s.age, s.sex, s.score)
}

func (t *Teacher) SayHello() {
	fmt.Printf("大家好，我是%s，我今年%d岁，我是%s生，我的学科是%d\n", t.name, t.age, t.sex, t.subject)
}

func main() {
	// 接口是一种数据类型 可以接收满足对象的信息
	var h Human
	stu := Student{"鸣人",18,"男",99}
	//stu.SayHello()
	h = &stu
	h.SayHello()
	tch := Teacher{"卡卡西",31,"男","复制忍术"}
	//tch.SayHello()
	// 将对象对峙给接口 必须满足接口中方法的声明格式
	h = &tch
	h.SayHello()
}
